//
//  ATTabBarViewController.m
//  TAUi
//
//  Created by Lin Buken on 16/1/11.
//  Copyright © 2016年 com.aiton. All rights reserved.
//

#import "ATTabBarViewController.h"
#import "CustomTabbar.h"
#import "CustomNavController.h"

@interface ATTabBarViewController ()<CustomTabbarDelegate,UITabBarControllerDelegate>

{
    NSArray *_tabArray;
    CustomTabbar *_costomtab;
}

@end

@implementation ATTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.tabBar.hidden = YES;
    NSArray *VcArray = @[@"ATOneViewController",
                         @"ATTwoViewController",
                         @"ATThreeViewController",
                         @"ATFourViewController",
                         @"ATFiveViewController",
                         @"ATSixViewController",
                         @"ATSevenViewController"];
    
    NSArray *VCTitles = @[@"手控",
                          @"时基",
                          @"相位",
                          @"冲突",
                          @"配时",
                          @"检测",
                          @"灯检"];
    
//    NSArray *image = @[@"tabbar_home_os7",
//                       @"tabbar_discover_os7",
//                       @"tabbar_more_os7",
//                       @"tabbar_home_os7",
//                       @"tabbar_discover_os7",
//                       @"tabbar_more_os7",
//                       @"tabbar_home_os7"];
    
//    NSArray *selectImage = @[@"tabbar_home_selected_os7",
//                             @"tabbar_discover_selected_os7",
//                             @"tabbar_more_selected_os7",
//                             @"tabbar_home_selected_os7",
//                             @"tabbar_discover_selected_os7",
//                             @"tabbar_more_selected_os7",
//                             @"tabbar_home_selected_os7"];
    NSArray *selectImage = @[@"radio_checked@2x",
                             @"radio_checked@2x",
                             @"radio_checked@2x",
                             @"radio_checked@2x",
                             @"radio_checked@2x",
                             @"radio_checked@2x",
                             @"radio_checked@2x"];

    
    CustomTabbar *customtabbar = [[CustomTabbar alloc] initWithTitles:VCTitles images:nil selectedImages:selectImage tabBarStyle:CustomTabbarStyleNormal norTextColor:[UIColor grayColor] selectedTextColor:[UIColor orangeColor] bgColor:[UIColor yellowColor] selectedColor:[UIColor cyanColor]];
    customtabbar.tabbarDelegate = self;
    customtabbar.tabBarFont = [UIFont systemFontOfSize:20];
    [self.view addSubview:customtabbar];
    NSMutableArray *tabArray = [NSMutableArray array];
    for (int i = 0; i < VcArray.count;i++) {
        Class cls = NSClassFromString(VcArray[i]);
        UIViewController*vc = [[cls alloc]init];
        CustomNavController*nav = [[CustomNavController alloc]initWithRootViewController:vc];
        [tabArray addObject:nav];
        _tabArray = tabArray;
    }
    self.viewControllers = tabArray;
    _costomtab = customtabbar;
}

//点击按钮显示
- (void) clickThisBtnAtIndex:(NSInteger)index{
    self.selectedIndex=index;
}
- (void)showTabbar{
    _costomtab.hidden=NO;
}
- (void)hiddenTabbar{
    _costomtab.hidden=YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
